﻿@model ForumTopicContainer
@using PopForums.Extensions;
@using PopForums.Models
@{
	ViewBag.Title = Model.Forum.Title;
	Layout = "~/Areas/PopForums/Views/Shared/PopForumsMaster.mobile.cshtml";
}

@if (Model.PermissionContext.UserCanPost)
{
	<p><a href="#PostNewTopic" data-role="button">@PopForums.Resources.PostNewTopic</a></p>
}
else
{
	<p>@Model.PermissionContext.DenialReason</p>
}

@if (this.GetUserFromViewData() != null)
{
	using (Html.BeginForm("MarkForumRead", "Forum", new { id = Model.Forum.ForumID }))
	{
		<p><input type="submit" value="@PopForums.Resources.MarkForumRead" class="pf-button" /></p>
	}
}

@Html.PagerLinksMobile(Url, "Forum", "Index", Model.PagerContext)

@helper TopicLink(Topic topic)
	{
	if (this.GetUserFromViewData() == null)
	{
		@Url.Action("Topic", "Forum", new { id = topic.UrlName, page = 1 })
	}
	else
	{
		@Url.Action("GoToNewestPost", "Forum", new { id = topic.TopicID })
	}
}

<ul class="pf-list pf-container">
	<li class="pf-list-item">
		<a href="@Url.Action("Index", PopForums.Controllers.ForumHomeController.Name)" class="pf-indicator-list-link">
			<div class="pf-back"> </div>
			<span class="pf-heading">@PopForums.Resources.ForumHome</span>
		</a>
	</li>
	@foreach (var topic in Model.Topics)
	{
		<li class="pf-list-item@(topic.IsDeleted ? Html.Raw(" deletedItem") : Html.Raw(""))">
			<a href="@TopicLink(topic)" class="pf-indicator-list-link">
				@Html.TopicReadIndicator(topic, Model, "/Content/PopForums/", "pf-indicator")
				<span class="pf-heading">@topic.Title</span>
				<span class="pf-subhead">@PopForums.Resources.Last: @FormatTime(topic.LastPostTime) @PopForums.Resources.By @topic.LastPostName</span>
			</a>
		</li>
	}
</ul>

@if (this.GetUserFromViewData() != null)
{
	<a name="PostNewTopic"></a>
	<h2>@PopForums.Resources.PostNewTopic</h2>
	<div>
		@{ Html.RenderAction("PostTopic", "Forum", new { id = Model.Forum.ForumID }); }
	</div>
}
